package gui.win.parameters;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JWindow;

/*Author: John Archer, Contact: john.archer.jpa@gmail.com*/
public class Buttons extends JPanel implements ActionListener{
    private JButton close;
    private JWindow ParaL0;
    public Buttons(JWindow ParaL0){
        super(new BorderLayout());
        this.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
        this.ParaL0 = ParaL0;
        this.add(getButton(close = new JButton("CLOSE"), 428, 22, new Color(102, 102, 102), new Color(178, 178, 178), this, "CLOSE"), BorderLayout.WEST);
        this.setVisible(true);
    }

    public void actionPerformed(ActionEvent evt) {
        Object source = evt.getSource();
        if(source == close){ParaL0.dispose();}
    }
    
    public static JPanel getButton(JButton st, int width, int height, Color fCol, Color bCol, ActionListener al, String tooltip){
        st.setForeground(fCol);
        st.setBackground(bCol);
        st.setPreferredSize(new Dimension(width, height));
        st.addActionListener(al);
        st.setToolTipText(tooltip);
        JPanel p = new JPanel(new FlowLayout());
        p.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
        p.setOpaque(false);
        p.add(st);
        return p;
    }
}